<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;

class ChangePassword extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'oldPassword' => 'required',
            'newPassword' => 'required',
            'c_newPassword' => 'required|same:newPassword'
        ];
    }

    public function messages()
    {
        return [
            'oldPassword.required' => '原密码必须填写',
            'newPassword.required' => '新密码必须填写',
            'c_newPassword.required' => '确认密码必须填写',
            'c_newPassword.same:newPassword' => '新密码和确认密码必须一样',
        ];
    }
}
